package com.guanyong.dao;

import com.guanyong.model.VideoCollectLogModel;
import com.guanyong.model.VideoPlayLogModel;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by mxk on 2017/5/26.
 * 播放日志
 */
public interface IVideoPlayLogDaoMapper {


    @Insert("INSERT INTO t_ad_vidoplayctlog" +
            "(f_classtype,f_userid,f_objectid,f_ip,f_apptype,f_phoneSN) VALUES"+
            "(#{fClasstype},#{fUserid},#{fObjectid},#{fIp},#{fApptype},#{fPhoneSN})")
    int insert(VideoPlayLogModel record);


    @Select("select * from t_ad_vidoplayctlog WHERE f_classtype=#{classtype} and " +
            " f_objectid=#{objectid} and f_userid=#{userid} LIMIT 1")
    @ResultMap("PlayLogResultMap")
    VideoPlayLogModel GetPlayModel(@Param("classtype") Integer classtype,
                                         @Param("objectid") String objectid,
                                         @Param("userid") String userid );

    @Select("select * from t_ad_vidoplayctlog WHERE f_id=#{id}")
    @ResultMap("PlayLogResultMap")
    VideoPlayLogModel GetPlayModelById(@Param("id") Integer id);


    List<VideoPlayLogModel> SelectPlayList(@Param("userid")String  userid,
                                           @Param("phoneSN") String phoneSN,
                                           @Param("isweek") Integer isweek,
                                           @Param("offset")Integer offset,
                                           @Param("limit") Integer limit);

    Integer SelectPlayListCount(@Param("userid")String  userid,@Param("phoneSN")String  phoneSN,@Param("isweek") Integer isweek);


    List<VideoPlayLogModel> SelectPlayListLog(@Param("userid")String  userid,
                                              @Param("phoneSN") String phoneSN,
                                              @Param("offset")Integer offset,
                                              @Param("limit") Integer limit);

    Integer SelectPlayListLogCount(@Param("userid")String  userid,@Param("phoneSN")String  phoneSN);



    //更新最新时间按
    @Update("update   t_ad_vidoplayctlog set f_intime =now() where f_id=#{id}")
    int updateIntime(Integer id);

    //取消观看记录
    @Delete("DELETE from t_ad_vidoplayctlog WHERE f_id=#{id}")
    int delete(Integer id);


    @Delete("DELETE from t_ad_vidoplayctlog WHERE f_userid='${userid}' and f_objectid in (${idList})")
    int deleteIdlist(@Param("userid")String  userid,@Param("idList")String  idList);
}
